/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package a1A;

import java.io.InputStreamReader;

/**
 *
 * @author nisarg
 */
public class scalar_product {
    public static void main(String[] args) {
        scalar_product a1 = new scalar_product();
        int[] a = {1,3,-4}; 
        int[] b = {-2,4,1};
        int len = a.length;
        int temp1 = 0,output=0;
        int swap;
        output = a1.scalar(a,b);
        //########     SWAP A's ELEMENT     #########
        for(int i=0;i<len-1;i++) {
            for(int j=0;j<len-1;j++) {
                swap = a[j];
                a[j] = a[j+1];
                a[j+1] = swap;
                int temp2 = a1.scalar(a,b);
                if(output>temp2) {
                    output = temp2;
                }
            }
        }
        
        //########     SWAP B's ELEMENT     #########
        for(int i=0;i<len-1;i++) {
            for(int j=0;j<len-1;j++) {
                swap = b[j];
                b[j] = b[j+1];
                b[j] = swap;
                int temp2 = a1.scalar(a,b);
                if(output>temp2) {
                    output = temp2;
                }
            }
        }
        System.out.println("Case#1: " + output);
        
        
        
        
        
        
        /*temp = a1.scalar(a,b);8?
        /*FOR ELEMENT OF ARRAY "A" */
        /*for(int i=0;i<=len;i++) {
            temp1 = a[0];
            //System.out.println("1");
            for(int j=0;j<(len-1);j++) {
                a[j] = a[j+1];
            }
            a[len-1] = temp1;
            int temp3 = a1.scalar(a,b);
            if(temp > temp3) {
                temp = temp3;
                //System.out.println("temp = " + temp);
            }
            else {
                //System.out.println("temp = " + temp +" temp3 = " + temp3);
            }
        }
        /*FOR ELEMENT OF ARRAY "B" */
        /*for(int i = 0;i<=len;i++) {
            //System.out.println("2");
            temp1 = b[0];
            for(int j=0;j<(len-1);j++) {
                b[j] = b[j+1];
                b[j] = temp1;
                int temp3 = a1.scalar(a,b);
                if(temp > temp3) {
                    temp = temp3;
                    //System.out.println("temp = " + temp);
                }
            }
        }
        System.out.println();
        System.out.println("output = " + temp);*/
    }
    public int scalar(int[] a,int[] b) {
        //System.out.println("");
        int i = 0;
        int len = a.length;
        int out = 0;
        //System.out.print("(");
        /*while(i<3) {
            System.out.print(a[i++]+",");
        }
        System.out.print(")");
        System.out.print(" x ");
        i=0;
        System.out.print("(");
        while(i<3) {
            System.out.print(b[i++]+",");
        }
        System.out.print(")");
        i=0;
        out=0;*/
        while(i<len) {
            out += a[i]*b[i];
            i++;
        }
        //System.out.print(" = " + out);
        return out;
    }
}
